import request from '@/utils/request'
import {lToMl, yuanToFen} from "@/utils/unitUtil";

// 查询加注机列表
export function listFacilit(query) {
  return request({
    url: '/consumer/facilit/list',
    method: 'get',
    params: query
  })
}

// 查询首页加注机列表
export function listFacilitIndex(query) {
  return request({
    url: '/consumer/facilit/get-list',
    method: 'get',
    params: query
  })
}

// 查询加注机详细
export function getFacilit(facilitId) {
  return request({
    url: '/consumer/facilit/' + facilitId,
    method: 'get'
  })
}

// 新增加注机
export function addFacilit(data) {
  const unit = yuanToFen(data.unitTemporary)
  const totalLiquid = lToMl(data.totalLiquid)
  const remainingLiquid = lToMl(data.remainingLiquid)
  data.totalLiquid = totalLiquid
  data.remainingLiquid = remainingLiquid
  data.unitTemporary = unit
  return request({
    url: '/consumer/facilit',
    method: 'post',
    data: data
  })
}

// 修改加注机
export function updateFacilit(data) {
  return request({
    url: '/consumer/facilit',
    method: 'put',
    data: data
  })
}

// 删除加注机
export function delFacilit(facilitId) {
  return request({
    url: '/consumer/facilit/' + facilitId,
    method: 'delete'
  })
}
